package com.woniuxy.house.mapper;

import com.woniuxy.house.entity.Post;
import com.woniuxy.house.entity.PostPictures;
import org.apache.ibatis.annotations.*;

import java.util.List;
/**
 * 帖子照片mapper接口
 *
 * */
public interface PostPictureMapper {
    /**
     * 根据帖子ID查帖子图片
     *
     * */

    @Select("select * from house_post_pictures where post_id=#{id}")
    @Results(id="result",value = {
            @Result(column = "id",property = "id",id = true),
            @Result(column = "picture",property = "picture"),
            @Result(column = "post_id",property = "post.id")
    })
   List<PostPictures> getByPostId(Integer postId);


    /**
     * 添加帖子图片
     * */

    @Insert("insert into house_post_pictures(picture,post_id) value(#{picture},#{post.id})")
    void add(PostPictures postPictures);


    /**
     * 根据id物理删除
     * */

    @Delete("delete from house_post_pictures where id=#{id}")
    void deleteById(Integer id);


    /**
     * 根据id和picture字段修改图片
     *
     * */

    @Update("update house_post_pictures set picture=#{picture} where id=#{id}")
    void updateById(@Param("id") Integer id,@Param("picture") String picture);
}
